package com.sky.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sky.po.DishFlavorPO;
import com.sky.repository.DishFlavorRepository;
import com.sky.service.DishFlavorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Content:
 * @Author: Asen
 * @Date: 2023/9/1 14:34
 */
@Slf4j
@Service
public class DishFlavorServiceImpl extends ServiceImpl<DishFlavorRepository, DishFlavorPO> implements DishFlavorService {
    @Autowired
    private DishFlavorRepository dishFlavorRepository;

    /**
     * 批量新增
     * @param source
     */
    public void insertBatch(List<DishFlavorPO> source){
        this.saveBatch(source,source.size());
    }

    /**
     * 根据菜品id批量删除
     * @param ids
     */
    @Override
    public void deleteByDishIdBatch(List<Long> ids) {
        dishFlavorRepository.delete(new LambdaQueryWrapper<DishFlavorPO>()
                .in(DishFlavorPO::getDishId,ids));
    }

    /**
     * 根据菜品id查询
     * @param id
     * @return
     */
    @Override
    public List<DishFlavorPO> getByDishId(Long id) {
        return dishFlavorRepository.selectList(new LambdaQueryWrapper<DishFlavorPO>()
                .eq(DishFlavorPO::getDishId,id));
    }
}
